#ifndef __MISC_H__
#define __MISC_H__

#define MIX(a, b, c) \
{ \
	a = a - b;		a = a - c;		a = a ^ (c >> 13); \
	b = b - c;		b = b - a;		b = b ^ (a << 8);  \
	c = c - a;		c = c - b;		c = c ^ (b >> 13); \
	a = a - b;		a = a - c;		a = a ^ (c >> 12); \
	b = b - c;		b = b - a;		b = b ^ (a << 16); \
	c = c - a;		c = c - b;		c = c ^ (b >> 5);  \
	a = a - b;		a = a - c;		a = a ^ (c >> 3);  \
	b = b - c;		b = b - a;		b = b ^ (a << 10); \
	c = c - a;		c = c - b;		c = c ^ (b >> 15); \
}

class CMisc
{
public:
	static std::string getIpPort( const std::string & ip, USHORT port );
	static void getIpPortFromStr( std::string& ip, U16& port, std::string strIPPort);
	static U32 ComputeLinearHash(const char* i_key);
	static U32 ComputeLinearHash(const void* i_key, int i_keyLen);
	static BOOL ToString(U8* pData, U32 dwLen, std::string& out);
	static BOOL FromString(U8* pOut, U32& dwLen, std::string& in);
};
#endif //__MISC_H__